home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / src / xfreadBox.tcl < prev    next >
Encoding:
Text File  |  1993-11-20  |  5.0 KB  |  159 lines

  1. # XFNoParsing
  2. # Program: template
  3. # Description: read TCL commands and send them to TCL
  4. #
  5. # $Header: xfreadBox.tcl[2.3] Wed Mar 10 12:08:10 1993 garfield@garfield frozen $
  6.  
  7. global xfReadBox
  8. set xfReadBox(activeBackground) ""
  9. set xfReadBox(activeForeground) ""
  10. set xfReadBox(background) ""
  11. set xfReadBox(font) ""
  12. set xfReadBox(foreground) ""
  13. set xfReadBox(scrollActiveForeground) ""
  14. set xfReadBox(scrollBackground) ""
  15. set xfReadBox(scrollForeground) ""
  16.  
  17. proc XFReadBox {} {# xf ignore me 5
  18. ##########
  19. # Procedure: XFReadBox
  20. # Description: show a box where tcl code can be entered and
  21. #              evaluated
  22. # Arguments: none
  23. # Returns: none
  24. # Sideeffects: may be everything...
  25. ##########
  26. #
  27. # global xfReadBox(activeBackground) - active background color
  28. # global xfReadBox(activeForeground) - active foreground color
  29. # global xfReadBox(background) - background color
  30. # global xfReadBox(font) - text font
  31. # global xfReadBox(foreground) - foreground color
  32. # global xfReadBox(scrollActiveForeground) - scrollbar active background color
  33. # global xfReadBox(scrollBackground) - scrollbar background color
  34. # global xfReadBox(scrollForeground) - scrollbar foreground color
  35. # global xfReadBox(scrollSide) - side where scrollbar is located
  36.  
  37.   global xfReadBox
  38.  
  39.   set tmpButtonOpt ""
  40.   set tmpFrameOpt ""
  41.   set tmpMessageOpt ""
  42.   set tmpScrollOpt ""
  43.   if {"$xfReadBox(activeBackground)" != ""} {
  44.     append tmpButtonOpt "-activebackground \"$xfReadBox(activeBackground)\" "
  45.   }
  46.   if {"$xfReadBox(activeForeground)" != ""} {
  47.     append tmpButtonOpt "-activeforeground \"$xfReadBox(activeForeground)\" "
  48.   }
  49.   if {"$xfReadBox(background)" != ""} {
  50.     append tmpButtonOpt "-background \"$xfReadBox(background)\" "
  51.     append tmpFrameOpt "-background \"$xfReadBox(background)\" "
  52.     append tmpMessageOpt "-background \"$xfReadBox(background)\" "
  53.   }
  54.   if {"$xfReadBox(font)" != ""} {
  55.     append tmpButtonOpt "-font \"$xfReadBox(font)\" "
  56.     append tmpMessageOpt "-font \"$xfReadBox(font)\" "
  57.   }
  58.   if {"$xfReadBox(foreground)" != ""} {
  59.     append tmpButtonOpt "-foreground \"$xfReadBox(foreground)\" "
  60.     append tmpMessageOpt "-foreground \"$xfReadBox(foreground)\" "
  61.   }
  62.   if {"$xfReadBox(scrollActiveForeground)" != ""} {
  63.     append tmpScrollOpt "-activeforeground \"$xfReadBox(scrollActiveForeground)\" "
  64.   }
  65.   if {"$xfReadBox(scrollBackground)" != ""} {
  66.     append tmpScrollOpt "-background \"$xfReadBox(scrollBackground)\" "
  67.   }
  68.   if {"$xfReadBox(scrollForeground)" != ""} {
  69.     append tmpScrollOpt "-foreground \"$xfReadBox(scrollForeground)\" "
  70.   }
  71.  
  72.   # build widget structure
  73.  
  74.   XFTmpltToplevel .xfReadBox 420x210 {XF read TCL commands}
  75.  
  76.   button .xfReadBox.ok \
  77.     -text "OK" \
  78.     -command {
  79.       if {"[info commands XFDestroy]" != ""} {
  80.         catch {XFDestroy .xfReadBox}
  81.       } {
  82.         catch {destroy .xfReadBox}
  83.       }}
  84.   catch ".xfReadBox.ok config $tmpButtonOpt"
  85.  
  86.   frame .xfReadBox.frame1 \
  87.     -borderwidth 0 \
  88.     -relief raised
  89.   catch ".xfReadBox.frame1 config $tmpFrameOpt"
  90.  
  91.   button .xfReadBox.frame1.send \
  92.     -text "Send" \
  93.     -command {
  94.       if {[catch "[string trim [.xfReadBox.text1.text1 get 1.0 end]]" result]} {
  95.         if {"[info commands XFAlertBox]" != ""} {
  96.           XFAlertBox "$result"
  97.         } {
  98.           puts stderr "$result"
  99.         }
  100.       }
  101.       flush stderr
  102.       flush stdout}
  103.   catch ".xfReadBox.frame1.send config $tmpButtonOpt"
  104.  
  105.   button .xfReadBox.frame1.sendAndClear \
  106.     -text "Send + Clear" \
  107.     -command {
  108.       if {[catch "[string trim [.xfReadBox.text1.text1 get 1.0 end]]" result]} {
  109.         if {"[info commands XFAlertBox]" != ""} {
  110.           XFAlertBox "$result"
  111.         } {
  112.           puts stderr "$result"
  113.         }
  114.       }
  115.       flush stderr
  116.       flush stdout
  117.       .xfReadBox.text1.text1 delete 1.0 end}
  118.   catch ".xfReadBox.frame1.sendAndClear config $tmpButtonOpt"
  119.  
  120.   button .xfReadBox.frame1.clear \
  121.     -text "Clear" \
  122.     -command {.xfReadBox.text1.text1 delete 1.0 end}
  123.   catch ".xfReadBox.frame1.clear config $tmpButtonOpt"
  124.  
  125.   frame .xfReadBox.text1 \
  126.     -borderwidth 0 \
  127.     -relief raised
  128.   catch ".xfReadBox.text1 config $tmpFrameOpt"
  129.  
  130.   scrollbar .xfReadBox.text1.scrollbar1 \
  131.     -command {.xfReadBox.text1.text1 yview} \
  132.     -relief "raised"
  133.   catch ".xfReadBox.text1.scrollbar1 config $tmpScrollOpt"
  134.  
  135.   text .xfReadBox.text1.text1 \
  136.     -borderwidth "2" \
  137.     -exportselection "true" \
  138.     -insertbackground "blue" \
  139.     -relief "raised" \
  140.     -yscrollcommand ".xfReadBox.text1.scrollbar1 set"
  141.   catch ".xfReadBox.text1.text1 config $tmpMessageOpt"
  142.  
  143.   # packing
  144.   pack append .xfReadBox.frame1 \
  145.               .xfReadBox.frame1.send {left fill expand} \
  146.               .xfReadBox.frame1.sendAndClear {left fill expand} \
  147.               .xfReadBox.frame1.clear {left fill expand}
  148.   pack append .xfReadBox.text1 \
  149.               .xfReadBox.text1.scrollbar1 "$xfReadBox(scrollSide) filly" \
  150.               .xfReadBox.text1.text1 {top expand fill}
  151.   pack append .xfReadBox \
  152.               .xfReadBox.ok {bottom fill} \
  153.               .xfReadBox.frame1 {bottom fill} \
  154.               .xfReadBox.text1 {bottom fill expand}
  155. }
  156.  
  157. # eof
  158.  
  159.